package com.jdz.gxq.info.admin.file.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.jdz.gxq.info.admin.file.service.FileService;
import com.jdz.gxq.info.common.action.CommonAction;
import com.jdz.gxq.info.common.constant.Constant;

public class DeleteImgAction extends CommonAction {

	private FileService fileService = null;
	 
	public ActionForward doExecute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws java.lang.Exception {
		
		String picId = request.getParameter("picId");
		
		// 文件上传相对路径
		String relativePath = Constant.IMAGE_PATH_ESTATE;
		
		// 取得的物理路径
		String realPath = request.getSession().getServletContext().getRealPath(relativePath);
		
		fileService.deleteImageInfo(picId, realPath);
	
		// 将上传后的文件信息返回画面
		response.getWriter().print("success");
		
		return null;
	}
	
	public void setFileService(FileService fileService) {
		this.fileService = fileService;
	}
}

